package BinarySearchTree;

import java.util.ArrayList;
import java.util.Random;

public class Main {

    public static void main(String[] args) {

        /*BST<Integer> bst = new BST<>();
        int[] nums = {5, 3, 6, 8, 4, 2};

        for(int num: nums)
            bst.add(num);

        bst.levelOrder();    //层序遍历*/

        /*bst.preOrder();
        System.out.println();

        bst.preOrderNR();*/

        /*bst.inOrder();
        System.out.println();

        bst.postOrder();
        System.out.println();
        System.out.println(bst);*/

        BST<Integer> bst = new BST<>();
        Random random = new Random();

        int n = 10;
        for(int i = 0; i < n; i++)
            bst.add(random.nextInt(100));

        ArrayList<Integer> nums = new ArrayList<>();
        while(!bst.isEmpty())
            nums.add(bst.removeMin());

        System.out.println(nums);
        for(int i = 0; i < nums.size() ; i++)
            if(nums.get(i -  1) > nums.get(i))
                throw new IllegalArgumentException("Error!");
        System.out.println("removeMin test completed!");
    }
}
